SVN to IRC commit bot
CommitOMatic is an SVN post-commit hook that connects to IRC and tells the logmessage.
Put this file as "post-commit" in the hooks directory of a subversion repository, and set the settings as you need.
Download#!/usr/bin/perl -w # see http://www.javalinux.it/wordpress/2009/10/15/writing-an-irc-bot-for-svn-commit-notification/ # see http://oreilly.com/pub/h/1964 use strict; # We will use a raw socket to connect to the IRC server. use IO::Socket; # The server to connect to and our details. my $server = "irc.freenode.net"; my $nick = "Commit-O-Matic"; my $login = "pulkobot"; my $channel = "#commits"; # END CONFIGURATION - NO NEED TO CHANGE ANYTHING BELOW my $repos = $ARGV[0]; my $rev = $ARGV[1]; my $commit = `/usr/bin/svnlook log $repos -r$rev`; my $user = `/usr/bin/svnlook author $repos -r$rev`; chomp $user; # Connect to the IRC server. my $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => 6667, Proto => 'tcp') or die "Can't connect\n"; # Log on to the server. print $sock "NICK $nick\r\n"; print $sock "USER $login 8 * :Commit-O-Matic Robot\r\n"; # Read lines from the server until it tells us we have connected. while (my $input = <$sock>) { # Check the numerical responses from the server. if ($input =~ /004/) { last; # exit the loop } elsif ($input =~ /433/) { die "Nickname is already in use."; } } # We are now logged in : join a channel print $sock "JOIN $channel\r\n"; # Now wait for the "end of name list" message while (my $input = <$sock>) { # Check the numerical responses from the server. if ($input =~ /366/) { last; # exit the loop } elsif ($input =~ /433/) { die "Nickname is already in use."; } } # We are now logged in. my $cmd = "PRIVMSG $channel :"; $repos =~ s#/home/subversion/##; print $sock "$cmd$repos: $user * r$rev\r\n"; chomp $commit; #svnlook add an extra newline. chomp $commit; #svnlook add an extra newline. my $com = $commit; $com =~ s/\n/\n$cmd/g; $com =~ s/^/$cmd/g; print $sock $com; print $sock "\n"; # Get out of it sleep(1); print $sock "QUIT bye... \r\n"; sleep(1); close($sock);